Skip to content

BluetoothSerial : Re-set _isRemoteAddressSet to false if connect() fails #6728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2022

Conversation

hepr-skylotec
Copy link
Contributor

@hepr-skylotec hepr-skylotec commented May 11, 2022

Description of Change

The BluetoothSerial library uses an internal _isRemoteAddressSet variable to track when a remote address has
been given. The connect() calls set this under certain circumstances, but fails to set it back to false if connection
fails. This causes subsequent calls to other functions such as discover() to fail without clear indications why.

Tests scenarios

I have tested this change on an Sparkfun ESP32 Thing Plus and connect() and subsequent discover() calls work as expected.

…ils.

The internal _isRemoteAddressSet variable is set to true
when calling connect() functions. If connecting fails _isRemoteAddressSet
needs to be re-set to false, otherwise other functions, such as
discover() will fail without clear error messages.
@CLAassistant
Copy link

CLAassistant commented May 11, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@mrengineer7777 mrengineer7777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. After studying BluetoothSerial.cpp, I can see the reason for _isRemoteAddressSet. This is a necessary bugfix. Checked program flow of new logic. Appears functionally equivalent. LGTM.

I will note that if _peer_bd_addr was a uint64_t instead of byte array, it could be checked for non-zero and replace the flag _isRemoteAddressSet. That's how I'm handling MAC addresses in my project, which utilizes the new library "MacAddress.h". Of course then you'd need to convert to the byte array when passing _peer_bd_addr to the native IDF functions.

@hepr-skylotec
Copy link
Contributor Author

hepr-skylotec commented May 16, 2022

Honestly, the entire BluetoothSerial.cpp could "use some improvement" regarding indentation and logging/debugging, and possibly also some parts of the functionality.

But I hesitate to submit a big whitespace patch, as such a thing would make it look like i wrote the entire thing if such a patch would be accepted.

Also, do I need to do anthing more to get attention to this and get it pulled?

@me-no-dev
Copy link
Member

Honestly, the entire BluetoothSerial.cpp could "use some improvement" regarding indentation and logging/debugging, and possibly also some parts of the functionality.

This will happen soon. We are just focused on other parts of the repository at the moment.

@me-no-dev me-no-dev merged commit 247bca8 into espressif:master May 27, 2022
@hepr-skylotec hepr-skylotec deleted the fix_isremoteaddressset branch April 5, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants